package asteroids.expressions;

import java.util.*;

import asteroids.types.*;

public abstract class LogicUnaryExpression extends UnaryExpression {

	protected LogicUnaryExpression(int line, int column, Expression expression) {
		super(line, column, expression);
	}

	@Override
	public List<String> getTypeCheckErrorsExpressions(List<String> typeErrors, Map<String, Type> globals) {
		if(getExpression().evaluate(null, globals).getClass() != BooleanType.class) 
			typeErrors.add("Line: " + getLine() + " Column: " + getColumn() + " - The expression, '" + getExpression().toString() + "' is expected to be from the type 'boolean'.");
		typeErrors = getExpression().getTypeCheckErrorsExpressions(typeErrors, globals);
		return typeErrors;
	}
	
}
